package algo.set;

import com.fay.algo.linkedlist.impl.LinkedList;
import com.fay.algo.linkedlist.impl.LinkedListNor;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/5/4 22:39
 * @Version 1.0
 */
public class LinkedListSet<E> implements Set<E> {
    private LinkedList<E> list;

    public LinkedListSet() {
        list = new LinkedList<>();
    }

    @Override
    public void add(E e) {
        if (!list.contains(e)) {
            list.addFirst(e);
        }
    }

    @Override
    public boolean contains(E e) {
        return list.contains(e);
    }

    @Override
    public void remove(E e) {
        list.removeElement(e);
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }
}
